﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_Login : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "管理员登录";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Cstudy.MODEL.users user = new Cstudy.MODEL.users();
        user.UserName = userName.Text.Trim();
        user.Pwd = userPwd.Text.Trim();
        DataSet ds = new Cstudy.BLL.Users().UserLogin(user);
        if (ds != null)
        {
            try
            {
                DataRow dr = ds.Tables[0].Rows[0];
                Session["username"] = dr["UserName"];
                Session["userid"] = dr["UserID"];
                Session["userpower"] = dr["UserPower"];
                if (Session["referrer"] != null)
                    Response.Redirect(Session["referrer"].ToString());
            }
            catch (Exception ex)
            { }
        }
        else
        {
            Response.Write("登录失败");
        }
    }
}